package chp12;

public class Tool {

    public void a(String name){
        System.out.println("一个参数,是字符串");
        System.out.println("hello," + name);
    }

    public void b(int a,int b){
        System.out.println("两个参数，参数都是整型");
        int sum = a + b;
        System.out.println("和是:" + sum);
    }

    public void c(String name,int age){
        System.out.println("两个参数，一个是字符串，一个是整型");
        System.out.println("姓名:"+name+" 年龄:" + age);
    }

    public void d(String account,int money){
        System.out.println("两个参数，一个是字符串，一个是整型");
        System.out.println("转账账号:" + account +" 金额:"+money);
    }

    //3个，4个，5个数的相加
    public void b3(int num1,int num2,int num3){
        System.out.println("三个参数，参数都是整型");
        int sum = num1 + num2 +num3;
        System.out.println("和是:" + sum);
    }
    public void b4(int num1,int num2,int num3,int num4){
        System.out.println("四个参数，参数都是整型");
        int sum = num1 + num2 +num3 + num4;
        System.out.println("和是:" + sum);
    }
    public void b5(int num1,int num2,int num3,int num4,int num5){
        System.out.println("五个参数，参数都是整型");
        int sum = num1 + num2 +num3+num4+num5;
        System.out.println("和是:" + sum);
    }


    public void e(int[] nums){
        System.out.println("一个参数，参数都是整型数组");
        for (int i = 0; i < nums.length; i++) {
            System.out.println(nums[i]);
        }
    }

    public void f(int[] nums){
        System.out.println("一个参数，参数都是整型数组");
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            sum += nums[i];
        }
        System.out.println("数组的和:"+sum);
    }

    public void g(String name,int age,String gender,String phone,String address) {
        System.out.println("五个参数，用来传递学生信息");
        System.out.println("姓名:" + name);
        System.out.println("年龄:" + age);
        System.out.println("性别:" + gender);
        System.out.println("电话:" + phone);
        System.out.println("家庭住址:" + address);
    }

    public void g2(Student student){
        System.out.println("一个参数，用对象来传递学生信息");
        System.out.println("姓名:" + student.name);
        System.out.println("年龄:" + student.age);
        System.out.println("性别:" + student.gender);
        System.out.println("电话:" + student.phone);
        System.out.println("家庭住址:" + student.address);
    }

    public static void main(String[] args) {
        Tool tool = new Tool();
//        tool.a("jack");
//        tool.b(10,9);
//        tool.c("jack",22);
//        tool.d("976524234324",9000);
//        tool.b3(1,2,3);
//        tool.b4(1,2,3,4);
//        tool.b5(1,2,3,4,5);
        //数组传参
//        int[] nums = {1,2,3,4,5};
//        tool.e(nums);
//        tool.f(nums);

//        tool.g("小明",19,"男","189","广州");

        Student student = new Student();
        student.name = "马拉";
        student.age = 22;
        student.gender = "女";
        student.phone = "98762";
        student.address = "深圳";

        tool.g2(student);

    }
}
